using System;
using Microsoft.AspNetCore.Http;

namespace _RobotInspection.DTO
{
    /// <summary>
    /// 日常点检设备卡片摘要DTO
    /// </summary>
    public class DailyEquipmentSummaryDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 设备ID
        /// </summary>
        public long EquipmentId { get; set; }

        /// <summary>
        /// 设备名称
        /// </summary>
        public string EquipmentName { get; set; }

        /// <summary>
        /// 设备编码
        /// </summary>
        public string EquipmentCode { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        public string CompanyName { get; set; }

        /// <summary>
        /// 机组
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 计划ID
        /// </summary>
        public long? PlanId { get; set; }

        /// <summary>
        /// 计划名称
        /// </summary>
        public string PlanName { get; set; }

        /// <summary>
        /// 计划类型：1-日，2-周，3-月，4-一次性
        /// </summary>
        public byte PlanType { get; set; }

        /// <summary>
        /// 计划类型名称
        /// </summary>
        public string PlanTypeName { get; set; }

        /// <summary>
        /// 频率值（如每天1次）
        /// </summary>
        public int? FrequencyValue { get; set; }

        /// <summary>
        /// 具体周期描述
        /// </summary>
        public string SpecificPeriod { get; set; }

        /// <summary>
        /// 任务状态：0-待执行，1-执行中，2-已完成，3-已超期
        /// </summary>
        public byte? TaskStatus { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 点检项次总数（来自inspection_plan_items）
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 已完成项次（来自inspection_records）
        /// </summary>
        public int DoneCount { get; set; }

        /// <summary>
        /// 是否已完成：1-已完成，0-未完成
        /// </summary>
        public int IsCompleted { get; set; }
    }

    /// <summary>
    /// 设备任务详情DTO（设备信息 + 点检项次列表）
    /// </summary>
    public class EquipmentTaskDetailDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 任务日期
        /// </summary>
        public DateTime TaskDate { get; set; }

        /// <summary>
        /// 任务状态：0-待执行，1-执行中，2-已完成，3-已超期
        /// </summary>
        public byte? TaskStatus { get; set; }

        /// <summary>
        /// 设备ID
        /// </summary>
        public long EquipmentId { get; set; }

        /// <summary>
        /// 设备名称
        /// </summary>
        public string EquipmentName { get; set; }

        /// <summary>
        /// 机组
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 指派用户ID
        /// </summary>
        public long AssignedUserId { get; set; }

        /// <summary>
        /// 指派用户姓名
        /// </summary>
        public string AssignedUserName { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 计划ID
        /// </summary>
        public long? PlanId { get; set; }

        /// <summary>
        /// 计划名称
        /// </summary>
        public string? PlanName { get; set; }

        /// <summary>
        /// 计划类型
        /// </summary>
        public byte? PlanType { get; set; }

        /// <summary>
        /// 点检项次列表（当前页）
        /// </summary>
        public List<InspectionRecordItemDto> Records { get; set; } = new List<InspectionRecordItemDto>();


    }

    /// <summary>
    /// 点检项次条目DTO（项次 + 执行记录）
    /// </summary>
    public class InspectionRecordItemDto
    {
        /// <summary>
        /// 记录ID（可能为空）
        /// </summary>
        public long? RecordId { get; set; }

        /// <summary>
        /// 点检项ID
        /// </summary>
        public long ItemId { get; set; }

        /// <summary>
        /// 点检项名称
        /// </summary>
        public string ItemName { get; set; }

        /// <summary>
        /// 点检项描述
        /// </summary>
        public string ItemDescription { get; set; }

        /// <summary>
        /// 标准值
        /// </summary>
        public string StandardValue { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 实际值
        /// </summary>
        public string ActualValue { get; set; }

        /// <summary>
        /// 结果状态：1-正常，2-异常，3-待处理
        /// </summary>
        public byte? ResultStatus { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedAt { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; }
    }

    /// <summary>
    /// 点检记录详情DTO
    /// </summary>
    public class InspectionRecordDetailDto
    {
        /// <summary>
        /// 记录ID
        /// </summary>
        public long RecordId { get; set; }

        /// <summary>
        /// 任务ID
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 点检项ID
        /// </summary>
        public long ItemId { get; set; }

        /// <summary>
        /// 点检标题
        /// </summary>
        public string InspectionTitle { get; set; }

        /// <summary>
        /// 点检内容
        /// </summary>
        public string InspectionContent { get; set; }

        /// <summary>
        /// 点检项名称
        /// </summary>
        public string ItemName { get; set; }

        /// <summary>
        /// 点检项描述
        /// </summary>
        public string ItemDescription { get; set; }

        /// <summary>
        /// 标准值
        /// </summary>
        public string StandardValue { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; }

        /// <summary>
        /// 实际值
        /// </summary>
        public string ActualValue { get; set; }

        /// <summary>
        /// 结果状态：1-正常，2-异常，3-待处理
        /// </summary>
        public byte ResultStatus { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 巡检照片路径
        /// </summary>
        public string InspectionPhotoPath { get; set; }

        /// <summary>
        /// 检查时间
        /// </summary>
        public DateTime? InspectionTime { get; set; }

        /// <summary>
        /// 问题描述
        /// </summary>
        public string IssueDescription { get; set; }

        /// <summary>
        /// 下一步委托方
        /// </summary>
        public string NextAssignParty { get; set; }

        /// <summary>
        /// 委托单号
        /// </summary>
        public string WorkOrderNo { get; set; }

        /// <summary>
        /// 检查人ID
        /// </summary>
        public long? InspectorId { get; set; }

        /// <summary>
        /// 检查人姓名
        /// </summary>
        public string InspectorName { get; set; }

        /// <summary>
        /// 修复图片路径
        /// </summary>
        public string RepairPhotoPath { get; set; }

        /// <summary>
        /// 修复结果：0-未修复，1-修复完成，2-修复失败
        /// </summary>
        public byte? RepairResult { get; set; }

        /// <summary>
        /// 修复时间
        /// </summary>
        public DateTime? RepairTime { get; set; }

        /// <summary>
        /// 修复人ID
        /// </summary>
        public long? RepairUserId { get; set; }

        /// <summary>
        /// 修复人姓名
        /// </summary>
        public string RepairUserName { get; set; }

        /// <summary>
        /// 设备ID
        /// </summary>
        public long EquipmentId { get; set; }

        /// <summary>
        /// 设备名称
        /// </summary>
        public string EquipmentName { get; set; }

        /// <summary>
        /// 设备编码
        /// </summary>
        public string EquipmentCode { get; set; }
    }

    /// <summary>
    /// 点检提交表单DTO（multipart/form-data）
    /// </summary>
    public class UpsertRecordSubmitDto
    {
        /// <summary>
        /// 点检记录ID（必填）
        /// </summary>
        public long? RecordId { get; set; }

        /// <summary>
        /// 任务ID（必填）
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 点检项ID（可空）
        /// </summary>
        public long ItemId { get; set; }

        /// <summary>
        /// 实际值（必填）
        /// </summary>
        public string ActualValue { get; set; }

        /// <summary>
        /// 点检结果：1-正常，2-异常，3-待处理（必填）
        /// </summary>
        public byte ResultStatus { get; set; }

        /// <summary>
        /// 点检备注（可选）
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 巡检照片文件（可选，图片类型）
        /// </summary>
        public IFormFile? InspectionPhoto { get; set; }

        /// <summary>
        /// 修复图片文件（可选，异常时可上传，图片类型）
        /// </summary>
        public IFormFile? RepairPhoto { get; set; }

        /// <summary>
        /// 检查时间（可选，不传默认当前时间）
        /// </summary>
        public DateTime? InspectionTime { get; set; }

        /// <summary>
        /// 问题描述（异常时建议填写）
        /// </summary>
        public string? IssueDescription { get; set; }

        /// <summary>
        /// 下一步责任方（异常时必填）
        /// </summary>
        public string? NextAssignParty { get; set; }

        /// <summary>
        /// 检查人ID（可选）
        /// </summary>
        public long? InspectorId { get; set; }

        /// <summary>
        /// 是否添加到关注事项（可选，默认否）
        /// </summary>
        public bool? AddAttentionItem { get; set; }

        /// <summary>
        /// 关注事项的异常名称（添加关注事项时建议填写）
        /// </summary>
        public string? AttentionAbnormalName { get; set; }

        /// <summary>
        /// 关注事项的异常描述（添加关注事项时可选）
        /// </summary>
        public string? AttentionDescription { get; set; }

        /// <summary>
        /// 关注事项上报人ID（添加关注事项时建议填写；默认使用 InspectorId）
        /// </summary>
        public long? ReporterUserId { get; set; }
    }
}